package com.jr.comtroller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.jr.service.TestService;
import com.jr.util.ExceptionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: ZhiHu.Liu
 * @date: 2020/3/23 4:40 下午
 */
@RestController
public class TestController {

    @Autowired
    TestService testService;

    @SentinelResource(value = "hello",blockHandler = "handleFlowException", blockHandlerClass = ExceptionUtil.class)
    @RequestMapping("/hello/{name}")
    public String hello(@PathVariable(value = "name") String name) {
        System.out.println(name);
        return testService.hello(name);
    }

    @SentinelResource(value = "test", blockHandler = "handleFlowException", blockHandlerClass = ExceptionUtil.class)
    @RequestMapping("/test/{name}")
    public String test(@PathVariable(value = "name") String name) {
        System.out.println(name);
        return testService.test(name);
    }


}
